<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>报价单</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link
      rel="stylesheet"
      href="../../layuiadmin/layui/css/layui.css"
      media="all"
    />
    <link
      rel="stylesheet"
      href="../../layuiadmin/style/admin.css"
      media="all"
    />
    <link
      rel="stylesheet"
      href="../../layuiadmin/style/style.css"
      media="all"
    />
    <link
      rel="stylesheet"
      href="../../layuiadmin/fonts/iconfont.css"
      media="all"
    />
  </head>
  <body>
    <div class="layui-fluid">
      <div class="layui-form-item">
        <span class="layui-breadcrumb"></span>
      </div>
      <img
        src="../../layuiadmin/images/backPage.png"
        class="backPreviousPage"
      />
      <button
        class="layui-btn layuiadmin-btn-useradmin downLoadWord"
        style="right: 15px"
      >
        <i class="iconfont icon-xiazai"></i>
        下载
      </button>
      <div class="time_axis">
        <div class="time_box">
          <div class="time_box_list">
            <ul class="time_horizontal"></ul>
          </div>
        </div>
      </div>
      <iframe id="pdf"></iframe>
      <div class="seePdfBox"></div>
    </div>
    <script src="../../layuiadmin/modules/const_config.js"></script>
    <script src="../../layuiadmin/modules/jTools.js"></script>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script>
      layui
        .config({
          base: "../../layuiadmin/", //静态资源所在路径
        })
        .extend({
          index: "lib/index", //主入口模块
        })
        .use(["index", "element"], function () {
          var $ = layui.$,
            form = layui.form,
            element = layui.element,
            proID = jTools.getQuery("proID"),
            projectName = jTools.getQuery("projectName"),
            projectNameNext = jTools.getQuery("projectNameNext");
          $(".layui-breadcrumb").html(
            '<a href="projectManagement.html">' +
              projectName +
              '</a><a href="javascript:history.go(-1)">' +
              projectNameNext +
              '</a><a href="javascript:history.go(-1)">报价单</a>'
          );
          element.init();
          permissionList();
          function permissionList() {
            $.ajax({
              type: "get",
              async: true, //异步执行
              url: base_url + "/outlineProjects/list/priceList/" + proID,
              headers: {
                Accept: "application/json; charset=utf-8",
                Authorization: layui.sessionData("userToken").key,
              },
              contentType: "application/json",
              success: function (data) {
                if (data.type == "success") {
                  if (data.data.length == 0) {
                  } else {
                    var data = data.data.reverse();
                    var html = "";
                    for (var i = 0; i < data.length; i++) {
                      if (i == data.length - 1) {
                        fileid = data[i].fileId;
                        html += `
                    <li class="time_horizontal_part" data-id="${data[i].id}">
                        <b class="active"></b>
                        ${data[i].createTime}<br/>
                    </li>`;
                        $("#pdf").attr(
                          "src",
                          "../../layuiadmin/web/viewer.html?file=" +
                            base_url +
                            "/outlineProjects/preview/priceList/1/" +
                            data[i].id
                        );
                      } else {
                        html += `
                    <li class="time_horizontal_part" data-id="${data[i].id}">
                        <b></b>
                        ${data[i].createTime}<br/>
                    </li>`;
                      }
                    }
                  }
                }
                $(".time_horizontal").html(html);
                $(".time_horizontal_part").on("click", function () {
                  var fileId = $(this).attr("data-id");
                  console.log(fileId);
                  $(this).children("b").addClass("active");
                  $(this).siblings("li").children("b").removeClass("active");
                  $("#pdf").attr(
                    "src",
                    "../../layuiadmin/web/viewer.html?file=" +
                      base_url +
                      "/outlineProjects/preview/priceList/1/" +
                      fileId
                  );
                });
                $(".downLoadWord").on("click", function () {
                  var fileId = $(".active").parent().attr("data-id");
                  window.location.href =
                    base_url + "/outlineProjects/download/priceList/" + fileId;
                });
                $(".time_horizontal").scrollLeft(
                  $(".time_horizontal")[0].scrollWidth
                );
              },
            });
          }
          $(".backPreviousPage").on("click", function () {
            window.history.back(-1);
          });
        });
    </script>
  </body>
</html>
